<?php
namespace app\mqtt\controller;

use Bluerhinos\phpMQTT;
use think\Controller;
use think\Request;

class Base extends Controller
{
    protected $logic;           # 每个控制下的逻辑层
    protected $accessKey;       # 入口KEY值
    protected $page;            # 分页参数
    protected $http;            # 域名地址
    protected $mqtt;
    protected $socketHost;       #socket服务器地址
    protected $socketPost;       #socket服务端口
    public function _initialize()
    {

        $host = "47.114.4.234"; //主机
        $port = 1883; //端口
        $username = "admin";
        $password = "admin";
        $this->mqtt = new phpMQTT($host, $port, "ClientID" . rand());
        if (!$this->mqtt->connect(true, NULL, $username, $password)) {
            exit(1);
        }
    }
}